<% if params[:collection_id] %>
<h1><%= Collection.find(params[:collection_id]).title%></h1>
<table>
  <tr>
    <th>Tome</th>
    <th>Price</th>
    <th>Description</th>
  </tr>
  <% if !@books.empty? %>
      <% @books.each do |book| %>
        <% if !UserBook.where("user_id = ? AND book_id = ?", current_user.id, book.id).empty? %>
        <tr>
          <td><%= book.title %></td>
          <td><%= book.price %></td>
          <td><%= book.description %></td>
        </tr>
        <% end %>
      <% end %>
  <% end %>
</table>

<%= link_to 'Edit', 'user_books/edit?collection_id=' + params[:collection_id] %>

<br />
<% else %>
<h1>All your books</h1>
<table>
  <tr>
    <th>Tome</th>
    <th>Price</th>
    <th>Description</th>
  </tr>
  <% if !@books.empty? %>
      <% @books.each do |book| %>
        <% if !UserBook.where("user_id = ? AND book_id = ?", current_user.id, book.id).empty? %>
        <tr>
          <td><%= Collection.find_by_id(book.collection_id).title %> <%= book.title %></td>
          <td><%= book.price %></td>
          <td><%= book.description %></td>
        </tr>
        <% end %>
      <% end %>
  <% end %>
</table>

<% end %>
